<?php
namespace app\home\controller;

use think\Cache;
use think\Controller;
use think\Cookie;
use think\Exception;
use think\Log;
use think\Session;
use app\home\validate;

class Demo extends Controller
{

    public function websoket()
    {
        return view("websocket");
    }
    public function  editormd(){
        return view("editormd");
    }
    public function place(){
        return view("PlaceSuggestion");
    }
    public function getAddress(){
        $address=$_POST["address"];
        $url="http://api.map.baidu.com/place/v2/suggestion?query=$address&region=上海市&city_limit=true&output=json&ak=306hhemTrKBMGV6hLBNIaU8nQd3Gkbco";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
        $result = curl_exec($ch);
        if(curl_errno($ch)){
            print_r(curl_error($ch));
        }
        curl_close($ch);
        $res=json_decode($result,TRUE);
        return json(["code"=>1,"msg"=>$res]);
    }
}
